#pragma once

#include <QObject>
#include <QVariant>
#include <QHashFunctions>
#include <QDataStream>
#include <QDebug>

#define TC_QML_ENUM_CLASS_NAME(Name) QmlEnumClass_##Name
#define TC_DECLARE_ENUM(Name, Reference) \
template<>\
inline QVariant QVariant::fromValue<Reference>(const Reference &val)\
{\
    return QVariant((uint)val);\
}\
template<>\
inline Reference QVariant::value<Reference>() const\
{\
    return (Reference)this->value<uint>();\
}\
inline uint qHash(const Reference &key)\
{\
    return qHash((uint)key);\
}\
inline QDataStream & operator >>(QDataStream &in, Reference &val)\
{\
    return in >> *(uint *)(&val);\
}\
inline QDataStream & operator <<(QDataStream &out, Reference val)\
{\
    return out << (uint)val;\
}\
inline QDebug operator <<(QDebug dbg, Reference val)\
{\
    return dbg << #Reference << "(" << (uint)val << ")";\
}
